package com.xywl.escort.view.dev

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.view.inputmethod.EditorInfo
import android.widget.Toast
import com.alibaba.android.arouter.facade.annotation.Route
import com.xywl.escort.R
import com.xywl.escort.common.PreferenceKeys.*
import com.xywl.escort.utils.RxSPTool
import kotlinx.android.synthetic.main.activity_verification.*

@Route(path = "/xy/verification")
class VerificationActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_verification)

        val pwd = edit_pwd.text

        edit_pwd.setOnEditorActionListener { _, actionId, _ ->
            when (actionId) {
                EditorInfo.IME_ACTION_DONE -> {
                    when (pwd.toString()) {
                        "2018" -> {
                            RxSPTool.putBoolean(this@VerificationActivity, IS_DEV, true)
                            RxSPTool.putBoolean(this@VerificationActivity, IS_LOG, true)
                            finish()
                        }
                        "0110" -> {
                            RxSPTool.putBoolean(this@VerificationActivity, IS_DEV, true)
                            RxSPTool.putBoolean(this@VerificationActivity, IS__ADMIN_DEV, true)
                            finish()
                        }
                        else -> {
                            Toast.makeText(this@VerificationActivity, "密码错误", Toast.LENGTH_SHORT).show()
                        }
                    }
                }
                else -> {
                }
            }
            false
        }
    }
}
